﻿<%@ Page Culture="auto" UICulture="auto" Title="Compare constraints" Language="C#"
    MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="CompareConstraintPage.aspx.cs"
    Inherits="BM.Tools.WebControls.MForm.Example.Constraints.CompareConstraintPage" %>

<%@ Register Assembly="BM.Tools.WebControls.MForm" Namespace="BM.Tools.WebControls.MForm.Controls"
    TagPrefix="mf" %>
<%@ Register Assembly="BM.Tools.WebControls.MForm" Namespace="BM.Tools.WebControls.MForm.Controls.Additions"
    TagPrefix="mfadd" %>
<%@ Register TagPrefix="mftitle" Namespace="BM.Tools.WebControls.MForm.Controls.Titles"
    Assembly="BM.Tools.WebControls.MForm" %>
<asp:Content ContentPlaceHolderID="Demonstration" runat="server">
    <p>
        In the following demonstration, even fields are compared to the preceding fields.
    </p>
    <ul>
        <li>The second field should have a greater date than the first field.</li>
        <li>The fourth field should have a smaller double than the third field.</li>
        <li>The sixth field should have a greater or equal amount of mney than the fifth field.</li>
        <li>The eighth field should have an equal text to the seventh field.</li>
    </ul>
    <mf:RootValidator runat="server" ControlToValidate="Root1" />
    <mf:Root ID="Root1" runat="server" Name="Root1">        
        <Contents>
            <mf:Branch runat="server" Name="CompareConstraintExample">
                <Contents>
                    <mf:Leaf runat="server" DataType="Date" Name="SomeDate" Ordinal="1">
                    </mf:Leaf>
                    <mf:Leaf runat="server" DataType="Date" Name="GreaterDate" Ordinal="2">
                        <Additions>
                            <mfadd:CompareConstraint runat="server" Type="Date" Operator="GreaterThan" ItemToComparePath="../SomeDate" />
                        </Additions>
                    </mf:Leaf>
                    <mf:Leaf runat="server" DataType="Double" Name="SomeDouble" Ordinal="3">
                    </mf:Leaf>
                    <mf:Leaf runat="server" DataType="Double" Name="SmallerDouble" Ordinal="4">
                        <Additions>
                            <mfadd:CompareConstraint runat="server" Type="Double" Operator="LessThan" ItemToComparePath="../SomeDouble" />
                        </Additions>
                    </mf:Leaf>
                    <mf:Leaf runat="server" DataType="Decimal" Name="SomeAmountOfMoney" Ordinal="5">
                        <Additions>
                            <mfadd:Restriction runat="server" RestrictionType="FractionDigits" Value="2" />
                        </Additions>
                    </mf:Leaf>
                    <mf:Leaf runat="server" DataType="Decimal" Name="GreaterOrEqualAmountOfMoney" Ordinal="6">
                        <Additions>
                            <mfadd:Restriction runat="server" RestrictionType="FractionDigits" Value="2" />
                            <mfadd:CompareConstraint runat="server" Type="Currency" Operator="GreaterThanEqual"
                                ItemToComparePath="../SomeAmountOfMoney" />
                        </Additions>
                    </mf:Leaf>
                    <mf:Leaf runat="server" Name="SomeText" Ordinal="7">
                    </mf:Leaf>
                    <mf:Leaf runat="server" Name="EqualText" Ordinal="8">
                        <Additions>
                            <mfadd:CompareConstraint runat="server" Type="String" Operator="Equal" ItemToComparePath="../SomeText" />
                        </Additions>
                    </mf:Leaf>
                </Contents>
            </mf:Branch>
        </Contents>
        <UriMappings>
            <mf:UriMapping Namespace="http://www.w3.org/2001/XMLSchema" Prefix="xs" />
            <mf:UriMapping Namespace="" Prefix="" />
        </UriMappings>
    </mf:Root>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="Description" runat="server">
    <p>
        The <code>compare constraint</code> provides the functionality of the ASP.NET Compare
        Validator to the MForm items.
    </p>
    <p>
        The <code>compare constraint</code> allows comparing the item's value to a fixed
        value or to a value of a different MForm item.
    </p>
    <p>
        The <code>compare constraint</code> control has the following properties:</p>
    <ul>
        <li><code>Type</code> - the comparison data type, an analogue of the <code>CompareValidator.Type</code>
            property</li>
        <li><code>ValueToCompare</code> - a fixed value the item is to be compared to, an analogue
            of the <code>CompareValiator.ValueToCompare</code> property.</li>
        <li><code>ItemToComparePath</code> - an xpath-like path to the item, whose value will
            be used for comparison (if both the <code>ValueToCompare</code> property and the
            <code>ItemToComparePath</code> property are set, the latter takes precedence)</li>
        <li><code>Operator</code> - the comparison operator: equal, not equal, greater than,
            greater than or equal, less than, less than or equal; an analogue of the <code>CompareValidator.Operator</code>
            property</li>
    </ul>
    <p>
        The <code>compare constraint</code> performs the validation by invoking both client
        and server side <code>CompareValidator's</code> validation methods. Thereby the
        behavior of this constraint should maximally resemble the behavior of the <code>CompareValidator</code>.
    </p>
</asp:Content>
